home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / lang / sofa.lha / sofa / smalleiffel / lib_se / globals.e < prev    next >
Text File  |  2000-03-25  |  11KB  |  451 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  4. --                       http://SmallEiffel.loria.fr
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
  11. -- for  more  details.  You  should  have  received a copy of the GNU General
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. deferred class GLOBALS
  17.    --
  18.    -- Global Tools for the SmallEiffel system.
  19.    --
  20.  
  21. inherit ALIASED_STRING_LIST; FROZEN_STRING_LIST;
  22.  
  23. feature
  24.  
  25.    frozen small_eiffel: SMALL_EIFFEL is
  26.       once
  27.          !!Result.make;
  28.       end;
  29.  
  30.    frozen eiffel_parser : EIFFEL_PARSER is
  31.       once
  32.          !!Result;
  33.       end;
  34.  
  35.    frozen run_control: RUN_CONTROL is
  36.       once
  37.          !!Result.make;
  38.       end;
  39.  
  40.    frozen eh: ERROR_HANDLER is
  41.       once
  42.          !!Result;
  43.       end;
  44.  
  45.    frozen string_aliaser: STRING_ALIASER is
  46.       once
  47.          !!Result.make;
  48.       end;
  49.  
  50.    frozen cpp: C_PRETTY_PRINTER is
  51.       once
  52.          !!Result;
  53.       end;
  54.  
  55.    frozen jvm: JVM is
  56.       once
  57.          !!Result.make;
  58.       end;
  59.  
  60.    frozen fmt: FMT is
  61.       once
  62.          !!Result.make;
  63.       end;
  64.  
  65.    frozen constant_pool: CONSTANT_POOL is
  66.       once
  67.          !!Result;
  68.       end;
  69.  
  70.    nb_errors: INTEGER is
  71.       do
  72.          Result := eh.error_counter;
  73.       ensure
  74.          Result >= 0
  75.       end;
  76.  
  77.    frozen gc_handler: GC_HANDLER is
  78.       once
  79.          !!Result.make;
  80.       end;
  81.  
  82. feature {SMALL_EIFFEL}
  83.  
  84.    frozen parser_buffer: PARSER_BUFFER is
  85.       once
  86.          !!Result.make;
  87.       end;
  88.  
  89. feature {NONE}
  90.  
  91.    frozen system_tools: SYSTEM_TOOLS is
  92.       once
  93.          !!Result.make;
  94.       end;
  95.  
  96.    frozen id_provider: ID_PROVIDER is
  97.       once
  98.          !!Result.make;
  99.       end;
  100.  
  101.    frozen manifest_string_pool: MANIFEST_STRING_POOL is
  102.       once
  103.          !!Result;
  104.       end;
  105.  
  106.    frozen manifest_array_pool: MANIFEST_ARRAY_POOL is
  107.       once
  108.          !!Result;
  109.       end;
  110.  
  111.    frozen once_routine_pool: ONCE_ROUTINE_POOL is
  112.       once
  113.          !!Result;
  114.       end;
  115.  
  116.    frozen cecil_pool: CECIL_POOL is
  117.       once
  118.          !!Result;
  119.       end;
  120.  
  121.    frozen address_of_pool: ADDRESS_OF_POOL is
  122.       once
  123.          !!Result;
  124.       end;
  125.  
  126.    frozen short_print: SHORT_PRINT is
  127.       once
  128.          !!Result.make;
  129.       end;
  130.  
  131.    frozen echo: ECHO is
  132.       once
  133.          !!Result.make;
  134.       end;
  135.  
  136.    frozen conversion_handler: CONVERSION_HANDLER is
  137.       once
  138.          !!Result;
  139.       end;
  140.  
  141.    frozen switch_collection: SWITCH_COLLECTION is
  142.       once
  143.       end;
  144.  
  145.    frozen assertion_collector: ASSERTION_COLLECTOR is
  146.       once
  147.          !!Result.make;
  148.       end;
  149.  
  150.    frozen exceptions_handler: EXCEPTIONS_HANDLER is
  151.       once
  152.          !!Result.make;
  153.       end;
  154.  
  155.    frozen field_info: FIELD_INFO is
  156.       once
  157.          !!Result;
  158.       end;
  159.  
  160.    frozen code_attribute: CODE_ATTRIBUTE is
  161.       once
  162.          !!Result;
  163.       end;
  164.  
  165.    frozen method_info: METHOD_INFO is
  166.       once
  167.          !!Result;
  168.       end;
  169.  
  170.    nb_warnings: INTEGER is
  171.       do
  172.          Result := eh.warning_counter;
  173.       ensure
  174.          Result >= 0
  175.       end;
  176.  
  177.    warning(p: POSITION; msg: STRING) is
  178.          -- Warning `msg' at position `p'.
  179.       require
  180.          not msg.is_empty
  181.       do
  182.          eh.add_position(p);
  183.          eh.append(msg);
  184.          eh.print_as_warning;
  185.       ensure
  186.          nb_warnings = old nb_warnings + 1
  187.       end;
  188.  
  189.    error(p: POSITION; msg: STRING) is
  190.          -- When error `msg' occurs at position `p'.
  191.       require
  192.          not msg.is_empty
  193.       do
  194.          eh.add_position(p);
  195.          eh.append(msg);
  196.          eh.print_as_error;
  197.       ensure
  198.          nb_errors = old nb_errors + 1
  199.       end;
  200.  
  201.    fatal_error(msg: STRING) is
  202.          -- Should not append but it is better to know :-)
  203.       require
  204.          not msg.is_empty
  205.       do
  206.          eh.append(msg);
  207.          eh.print_as_fatal_error;
  208.       end;
  209.  
  210.    tmp_path: STRING is
  211.       once
  212.          !!Result.make(512);
  213.       end;
  214.  
  215.    tmp_file_read: STD_FILE_READ is
  216.       once
  217.          !!Result.make;
  218.       end;
  219.  
  220.    class_any: BASE_CLASS is
  221.       once
  222.          Result := small_eiffel.get_class(as_any);
  223.       end;
  224.  
  225.    class_general: BASE_CLASS is
  226.       once
  227.          Result := small_eiffel.get_class(as_general);
  228.       end;
  229.  
  230.    type_boolean: TYPE_BOOLEAN is
  231.       local
  232.          unknown_position: POSITION;
  233.       once
  234.          !!Result.make(unknown_position);
  235.       end;
  236.  
  237.    type_string: TYPE_STRING is
  238.       local
  239.          unknown_position: POSITION;
  240.       once
  241.          !!Result.make(unknown_position);
  242.       end;
  243.  
  244.    type_any: TYPE_ANY is
  245.       local
  246.          unknown_position: POSITION;
  247.       once
  248.          !!Result.make(unknown_position);
  249.       end;
  250.  
  251.    type_pointer: TYPE_POINTER is
  252.       local
  253.          unknown_position: POSITION;
  254.       once
  255.          !!Result.make(unknown_position);
  256.       end;
  257.  
  258.    sort_running(run: ARRAY[RUN_CLASS]) is
  259.          -- Sort `run' to put small `id' first.
  260.       require
  261.          run.lower = 1;
  262.          run.upper >= 2;
  263.       local
  264.          min, max, buble: INTEGER;
  265.          moved: BOOLEAN;
  266.       do
  267.          from
  268.             max := run.upper;
  269.             min := 1;
  270.             moved := true;
  271.          until
  272.             not moved
  273.          loop
  274.             moved := false;
  275.             if max - min > 0 then
  276.                from
  277.                   buble := min + 1;
  278.                until
  279.                   buble > max
  280.                loop
  281.                   if run.item(buble - 1).id > run.item(buble).id then
  282.                      run.swap(buble - 1,buble);
  283.                      moved := true;
  284.                   end;
  285.                   buble := buble + 1;
  286.                end;
  287.                max := max - 1;
  288.             end;
  289.             if moved and then max - min > 0 then
  290.                from
  291.                   moved := false;
  292.                   buble := max - 1;
  293.                until
  294.                   buble < min
  295.                loop
  296.                   if run.item(buble).id > run.item(buble + 1).id then
  297.                      run.swap(buble,buble + 1);
  298.                      moved := true;
  299.                   end;
  300.                   buble := buble - 1;
  301.                end;
  302.                min := min + 1;
  303.             end;
  304.          end;
  305.       end;
  306.  
  307.    no_errors: BOOLEAN is
  308.       do
  309.          Result := nb_errors = 0;
  310.       end;
  311.  
  312.    character_coding(c: CHARACTER; str: STRING) is
  313.          -- Append in `str' the Eiffel coding of the character (Table
  314.          -- in chapter 25 of ETL, page 423).
  315.          -- When letter notation exists, it is returned in priority :
  316.          --  '%N' gives "%N", '%T' gives "%T", ...
  317.          -- When letter notation does not exists (not in ETL table),
  318.          -- numbered coding is used ("%/1/", "%/2/" etc).
  319.       local
  320.          special: CHARACTER
  321.       do
  322.          inspect
  323.             c
  324.          when '%A' then special := 'A';
  325.          when '%B' then special := 'B';
  326.          when '%C' then special := 'C';
  327.          when '%D' then special := 'D';
  328.          when '%F' then special := 'F';
  329.          when '%H' then special := 'H';
  330.          when '%L' then special := 'L';
  331.          when '%N' then special := 'N';
  332.          when '%Q' then special := 'Q';
  333.          when '%R' then special := 'R';
  334.          when '%S' then special := 'S';
  335.          when '%T' then special := 'T';
  336.          when '%U' then special := 'U';
  337.          when '%V' then special := 'V';
  338.          when '%%' then special := '%%';
  339.          when '%'' then special := '%'';
  340.          when '%"' then special := '"';
  341.          when '%(' then special := '(';
  342.          when '%)' then special := ')';
  343.          when '%<' then special := '<';
  344.          when '%>' then special := '>';
  345.          else
  346.          end;
  347.          str.extend('%%');
  348.          if special = '%U' then
  349.             str.extend('/');
  350.             c.code.append_in(str);
  351.             str.extend('/');
  352.          else
  353.             str.extend(special);
  354.          end;
  355.       end;
  356.  
  357.    fatal_error_vtec_2 is
  358.       do
  359.          fatal_error("Expanded class must have no creation procedure,%
  360.                       % or only one creation procedure with%
  361.                       % no arguments (VTEC.2).");
  362.       end;
  363.  
  364.    eiffel_suffix: STRING is ".e";
  365.          -- Eiffel Source file suffix.
  366.  
  367.    c_suffix: STRING is ".c";
  368.          -- C files suffix.
  369.  
  370.    h_suffix: STRING is ".h";
  371.          -- Heading C files suffix.
  372.  
  373.    c_plus_plus_suffix: STRING is ".cpp";
  374.          -- C++ files suffix.
  375.  
  376.    backup_suffix: STRING is ".bak";
  377.          -- Backup suffix for command `pretty'.
  378.  
  379.    help_suffix: STRING is ".txt";
  380.          -- Suffix for SmallEiffel On-line Help Files.
  381.  
  382.    class_suffix: STRING is ".class";
  383.  
  384.    dot_precedence: INTEGER is 12;
  385.          -- The highest precedence value according to ETL.
  386.  
  387.    atomic_precedence: INTEGER is 13;
  388.          -- Used for atomic elements.
  389.  
  390.    jvm_root_class: STRING is
  391.          -- Fully qualified name for the jvm SmallEiffel object's
  392.          -- added root : "<Package>/<fz_jvm_root>".
  393.       once
  394.          !!Result.make(12);
  395.          Result.copy(run_control.output_name);
  396.          Result.extend('/');
  397.          Result.append(fz_jvm_root);
  398.       end;
  399.  
  400.    jvm_root_descriptor: STRING is
  401.          -- Descriptor for `jvm_root_class': "L<jvm_root_class>;"
  402.       once
  403.          !!Result.make(12);
  404.          Result.extend('L');
  405.          Result.append(jvm_root_class);
  406.          Result.extend(';');
  407.       end;
  408.  
  409.    append_u1(str: STRING; u1: INTEGER) is
  410.       require
  411.          u1.in_range(0,255);
  412.       do
  413.          str.extend(u1.to_character);
  414.       end;
  415.  
  416.    append_u2(str: STRING; u2: INTEGER) is
  417.       require
  418.          u2.in_range(0,65536)
  419.       do
  420.          append_u1(str,u2 // 256);
  421.          append_u1(str,u2 \\ 256);
  422.       end;
  423.  
  424.    append_u4(str: STRING; u4: INTEGER) is
  425.       require
  426.          u4.in_range(0,(2 ^ 31) - 1)
  427.       do
  428.          append_u2(str,u4 // 65536);
  429.          append_u2(str,u4 \\ 65536);
  430.       end;
  431.  
  432.    c_frame_descriptor_local_count: COUNTER is
  433.          -- Current is not in this total.
  434.       once
  435.          !!Result;
  436.       end;
  437.  
  438.    c_frame_descriptor_format: STRING is
  439.          -- The format to print Current and other locals.
  440.       once
  441.          !!Result.make(512);
  442.       end;
  443.  
  444.    c_frame_descriptor_locals: STRING is
  445.          -- To initialize field `locals' of `se_dump_stack'.
  446.       once
  447.          !!Result.make(512);
  448.       end;
  449.  
  450. end -- GLOBALS
  451.